package main

import (
	"fmt"
	"strings"
)

func main() {
	input := "A man, a plan, a canal: Panama"
	// input := "race a car"
	// input := " "
	// input := "0P"
	v := isPalindrome(input)
	fmt.Println(v)
}

func isPalindrome(s string) bool {
	p1, p2 := 0, len(s)-1
	for {
		if p2 < p1 {
			return true
		}

		if !((s[p1] >= 'a' && s[p1] <= 'z') || (s[p1] >= '0' && s[p1] <= '9') || (s[p1] >= 'A' && s[p1] <= 'Z')) {
			p1++
			continue
		}
		if !((s[p2] >= 'a' && s[p2] <= 'z') || (s[p2] >= '0' && s[p2] <= '9') || (s[p2] >= 'A' && s[p2] <= 'Z')) {
			p2--
			continue
		}

		if strings.EqualFold(string(s[p1]), string(s[p2])) {
			p1++
			p2--
			continue
		} else {
			return false
		}
	}
}
